package com.wlw.service;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wlw.entity.City;
import com.wlw.entity.QA;

import edu.xjsoft.base.service.DefaultEntityManager;

@Service
@Transactional
public class QAService extends DefaultEntityManager<QA> {
	
	//最新5条问答
	public List<QA> qAlist(){
		String hql = "select q from QA q order by time desc";
		Query query = getEntityDao().createQuery(hql);
		query.setFirstResult(0);
		query.setMaxResults(5);
		List<QA> qas = query.list();
		return qas;
	}
	//查询问答：
	public List<QA> searchQA(String name){
		String hql = "select q from QA q where q.title like ?";
		List<QA> qas = getEntityDao().find(hql, "%"+name+"%");
		return qas;
	}
}
